Skip to content

Refactored Phenotype Enum; Added ATOW Attributes to Character Generation; Added 'Extra Attribute Randomization' Campaign Option #6564

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Apr 12, 2025

Conversation

IllianiBird
Copy link
Collaborator

@IllianiBird IllianiBird commented Apr 6, 2025

Requirements

Requires #6607

Dev Notes

Phenotypes

Certain phenotypes increase or decrease attributes. Some phenotypes also provide specific Traits (SPAs, in our nomenclature). Both of these cases are now fully implemented. I also went ahead and cleaned up the enum a bit, switching it over to i18n and updating the Unit Tests.

Professions

ATOW includes a few archetypes which offer suggested starting points for each attribute score. I've set up the code so that characters will generate (on average) with those attribute scores. However, a few of the examples provided in the manuals are straight up awful.

The Tanker archetype is the worst example. If I were to implement that Archetype most vehicle crew would spawn with a -1 penalty to both gunnery and piloting. Needless to say, that shan't be happening.

So while the code is set up to handle role-based attribute starting points, currently they're all set up to infer no modifier. I'm hoping to encourage a knowledgeable community member into providing some suggested starting attributes for our different professions. Once that's been sourced I can go in an update this (possibly in a separate PR).

Edit: This turned out to be an error in the manuals. I've since gone through and updated the Professions to have appropriate starting Attribute scores.

Campaign Options & Character Generation

When a character is generated, they are done so with 5 in every Attribute. A d6 is then rolled for each Attribute. On a roll of 1 the Attribute is decreased by 1; on a roll of 6 the Attribute is increased by 1.

In Campaign Options players can enable 'Extra Random Attributes'. This works identical to the above, however the d6 will 'explode'. What this means is if you roll a 1, you decrease the Attribute by 1 and then roll again. And keep going until you stop rolling 1s (or hit the minimum Attribute score of 1 - this isn't Traveller, nobody is dying in character creation). Conversely, if you roll a 6 you keep increasing the Attribute score by 1 until you stop rolling 6s (or hit the maximum Attribute score of 10).

- Replaced static resource-based getters in `Phenotype` with dynamic methods using resource bundles (`getLabel`, `getTooltip`, `getShortName`).
- Introduced attribute modifiers and bonus traits for `Phenotype`.
- Added the `isTrueborn` method for Clan phenotype classification.
- Deprecation of legacy methods like `getToolTipText`, `getName`, `parseFromString`, and `getGroupingName`.
- Reimplemented parsing logic with the `fromString` method supporting legacy inputs, labels, and ordinal formats.
- Implemented and applied random attribute generation in `RandomSkillPreferences` and `DefaultPersonnelGenerator`.
- Added UI elements and tooltips for randomizing attributes.
- Enhanced unit tests for attribute randomization and label validity.
- Added phenotype-based SPA generation by incorporating bonus traits from a character's phenotype.
- Imported `LVL3_ADVANTAGES` and adjusted logic to acquire phenotype traits as abilities.
- Refactored minor formatting issues for improved readability.
@IllianiBird IllianiBird added Personnel Personnel-related Issues Tests Issues or Pull Requests related to the project tests Implementation of Missing Official Rule Used with the RFE tag for the implementation of missing official rule labels Apr 6, 2025
@IllianiBird IllianiBird self-assigned this Apr 6, 2025
Copy link

codecov bot commented Apr 6, 2025

Codecov Report

Attention: Patch coverage is 16.49269% with 800 lines in your changes missing coverage. Please review.

Project coverage is 11.44%. Comparing base (34e0da5) to head (95732d3).
Report is 24 commits behind head on master.

Files with missing lines Patch % Lines
...ekhq/gui/panels/CompanyGenerationOptionsPanel.java 0.00% 324 Missing ⚠️
MekHQ/src/mekhq/gui/dialog/GMToolsDialog.java 0.00% 121 Missing ⚠️
MekHQ/src/mekhq/campaign/MercRosterAccess.java 0.00% 49 Missing ⚠️
...HQ/src/mekhq/gui/dialog/PersonnelMarketDialog.java 0.00% 44 Missing ⚠️
...rc/mekhq/campaign/personnel/skills/Attributes.java 55.42% 19 Missing and 18 partials ⚠️
...kHQ/src/mekhq/campaign/report/PersonnelReport.java 0.00% 30 Missing ⚠️
...kHQ/src/mekhq/campaign/market/PersonnelMarket.java 0.00% 24 Missing ⚠️
MekHQ/src/mekhq/campaign/personnel/Person.java 7.69% 23 Missing and 1 partial ⚠️
...ign/personnel/generator/DefaultSkillGenerator.java 0.00% 23 Missing ⚠️
...src/mekhq/gui/enums/PersonnelTableModelColumn.java 8.33% 22 Missing ⚠️
... and 15 more
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #6564      +/-   ##
============================================
- Coverage     11.44%   11.44%   -0.01%     
+ Complexity     6474     6469       -5     
============================================
  Files          1089     1090       +1     
  Lines        140180   140301     +121     
  Branches      21745    21776      +31     
============================================
+ Hits          16041    16052      +11     
- Misses       122505   122597      +92     
- Partials       1634     1652      +18     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

…and align with localized key usage.

- Refactored and standardized string formatting across affected files for improved readability.
- Removed hardcoded personnel role strings from `Personnel.properties` and introduced `PersonnelRole.properties` to centralize localization resources.
- Replaced `parseFromString` method with `fromString` for improved method naming and expanded functionality, including handling deprecated names and case variations.
- Added unit tests to validate new `getLabel` functionality, `fromString` method, and missing resource keys for roles.
- Updated XML generation and parsing methods to utilize the new role localization handling with `getLabel`.
@IllianiBird
Copy link
Collaborator Author

Updated to incorporate the ATOW and ATOW:Companion attributes.

I'm going to mark this as draft, as there is one last thing I want to do.

@IllianiBird IllianiBird marked this pull request as draft April 6, 2025 22:42
…te random roleplay attributes for personnel.es.
…Random Roleplay Attributes" to "Reset Roleplay Attributes."
@IllianiBird
Copy link
Collaborator Author

Added a personnel right-click menu GM option to set ATOW Attributes for existing characters.

@IllianiBird IllianiBird marked this pull request as ready for review April 6, 2025 22:58
@IllianiBird
Copy link
Collaborator Author

Flipping this back to live from draft

… SPAs

- Introduced a new `AttributeScoreSorter` for comparing "x / y" formatted strings, sorting by primary and secondary values.
- Updated attribute display and sorting in `PersonnelTableModelColumn` to represent both current scores and caps ("x / y").
- Added new "Exceptional Attribute" SPAs to increase attribute caps.
- Modified phenotype definitions in `Phenotype` to include attribute caps specific to each phenotype.
- Adjusted attribute handling logic to respect both phenotype caps and SPA adjustments.
- Enhanced unit tests to verify attribute caps and ensure adherence to defined ranges.
# Conflicts:
#	MekHQ/src/mekhq/campaign/personnel/skills/Attributes.java
@IllianiBird
Copy link
Collaborator Author

Added Attribute Maximums Based on Phenotype and Exceptional Attribute SPAs

  • Introduced a new AttributeScoreSorter for comparing "x / y" formatted strings, sorting by primary and secondary values.
  • Updated attribute display and sorting in PersonnelTableModelColumn to represent both current scores and caps ("x / y").
  • Added new "Exceptional Attribute" SPAs to increase attribute caps.
  • Modified phenotype definitions in Phenotype to include attribute caps specific to each phenotype.
  • Adjusted attribute handling logic to respect both phenotype caps and SPA adjustments.
  • Enhanced unit tests to verify attribute caps and ensure adherence to defined ranges.

# Conflicts:
#	MekHQ/data/universe/defaultspa.xml
#	MekHQ/resources/mekhq/resources/CampaignOptionsDialog.properties
#	MekHQ/resources/mekhq/resources/GUI.properties
#	MekHQ/src/mekhq/campaign/RandomSkillPreferences.java
#	MekHQ/src/mekhq/campaign/personnel/Person.java
#	MekHQ/src/mekhq/campaign/personnel/generator/DefaultPersonnelGenerator.java
#	MekHQ/src/mekhq/campaign/personnel/generator/DefaultSkillGenerator.java
#	MekHQ/src/mekhq/gui/adapter/PersonnelTableMouseAdapter.java
#	MekHQ/src/mekhq/gui/campaignOptions/contents/AdvancementTab.java
@IllianiBird IllianiBird merged commit 1d78eb8 into MegaMek:master Apr 12, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Implementation of Missing Official Rule Used with the RFE tag for the implementation of missing official rule Personnel Personnel-related Issues Tests Issues or Pull Requests related to the project tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant